﻿using System;
using System.Collections;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Text;
using QAHelper.Common;
using WatiN.Core;

namespace WatiNTest
{
    public class TestBase
    {
        #region Global Variables

        public TestScenario scenario = null;
        public TestCaseStructure testCaseStructure = new TestCaseStructure();
        public ArrayList headerListBase = new ArrayList();
        public ArrayList dataSetHeader = new ArrayList();
        public ArrayList testData = new ArrayList();
        public Browser window = null;
        public string rawRowData = string.Empty;

        public static ArrayList tempTestData = null; //Hold current row test data

        #endregion

        #region Init Test

        [TestInitialize]        
        public void InitTest()
        {
            scenario = TestManager.testScenario;

            #region Data Preparation

            if ((rawRowData = scenario.TestData) != null)
            {
                tempTestData = CommonHelper.GetFormattedDataSet(rawRowData);
            }

            #endregion


            if (TestManager.BROWSER_TYPE.ToString() == BrowserType.IE.ToString())
            {
                window = new IE(TestManager.URL_TO_TEST);
            }
            else if (TestManager.BROWSER_TYPE.ToString() == BrowserType.Firefox.ToString())
            {
                window = new FireFox(TestManager.URL_TO_TEST);
            }
            TestManager.browser = window;
            window.ShowWindow(WatiN.Core.Native.Windows.NativeMethods.WindowShowStyle.Maximize);            
        }
        

        #endregion

        #region Teardown Test

        [TestCleanup]
        public void TeardownTest ()
        {
            window.Dispose();
        }

        #endregion

    }
}
